import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

function route (path, file, name, children) {
  return {
    exact: true,
    path,
    name,
    children,
    component: () => import('./views' + file)
  }
}

export default new Router({
  routes: [
    route("/login",'/Login',"Login"),// /login路径，路由到登录组件
    route("/403",'/403',"403"),// /login路径，路由到登录组件
    route("/404",'/404',"404"),// /login路径，路由到登录组件
    {
      path:"*", // 根路径，路由到 Layout组件
      component: () => import('./views/404'),
      redirect:"/404",
    },
    {
      path:"/", // 根路径，路由到 Layout组件
      component: () => import('./views/Login'),
      redirect:"/login",
    },
    {
      path:"/index", // 根路径，路由到 Layout组件
      component: () => import('./views/Layout'),
      redirect:"/index/dashboard",
      children:[ // 其它所有组件都是 Layout的子组件
          //统计分析
        route("/index/dashboard","/Dashboard","Dashboard"),
          //歌单列表
        route("/song/songList","/song/SongList","SongList"),
        route("/song/songs","/song/Songs","Songs"),
          //歌单页面跳转到选择歌曲
        route("/song/allSongs","/song/AllSongs","AllSongs"),
        route("/song/category","/song/Category","Category"),
        //歌手管理
        route("/song/chooseSongs","/song/ChooseSongs","ChooseSongs"),
        route("/singer/singer","/singer/Singer","Singer"),
          //审核管理
        route("/upload/check","/upload/Check","Check"),
        route("/upload/playerpage","/upload/PlayerPage","PlayerPage"),
          //用户列表
        route("/user/userList","/user/UserList","UserList"),
        // 定义的是路径hash值与组件位置的映射关系
        // 第一个参数：路径hash值，第二个参数：组件的位置，相对于src/views，第三个参数是组件名称
        route("/auth/member",'/auth/Member',"Member"),
        route("/auth/services",'/auth/Services',"Services"),
        route("/auth/role",'/auth/Role',"Role"),
        //  权限页面
        route("/auth/authority",'/auth/Authority',"Authority"),
        route("/auth/authorityTree",'/auth/AuthorityTree',"AuthorityTree"),
      ]
    }
  ]
})
